<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <script src="../../echarts/echarts.js"></script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layuimini-container">
            <div class="layuimini-main">
                <fieldset class="layui-elem-field layui-field-title">
                    <legend>统计数据</legend>
                </fieldset>
                <div class="layui-row">
                    <div class="layui-col-md12">
                        <div class="layui-card-body">
                            <!--图表一和图表二-->
                            <div class="layui-row layui-col-space15">
                                <div class="layui-col-md6">
                                    <div class="layui-card" style="box-shadow: 0px 0px 10px 3px gainsboro; border-radius: 20px;">
                                        <div class="layui-card-header" style="font-weight: bold; font-size: 18px;"><i class="layui-icon layui-icon-slider"></i>成员人数统计</div>
                                        <div class="layui-card-body">
                                            <div id="main" style="width: 100%; height: 400px;">
                                                <script>
                                                    var chartDom = document.getElementById('main');
                                                    var myChart = echarts.init(chartDom);
                                                    var option;

                                                    option = {
                                                        xAxis: {
                                                            type: 'category',
                                                            data: ['计算机学院', '化学学院', '机械学院', '经管学院', '法学院', '电子学院', '环安学院']
                                                        },
                                                        yAxis: {
                                                            type: 'value'
                                                        },
                                                        series: [{
                                                            data: [1200, 2000, 1500, 800, 700, 1100, 1300],
                                                            type: 'bar',
                                                            showBackground: true,
                                                            backgroundStyle: {
                                                                color: 'pink'
                                                            }
                                                        }]
                                                    };

                                                    option && myChart.setOption(option);
                                                </script>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <div class="layui-card" style="border-radius: 20px; border: 2px solid buttonface; box-shadow: 0px 0px 10px 3px gainsboro;">
                                        <div class="layui-card-header" style="font-weight: bold; font-size: 18px;">成员人数统计</div>
                                        <div class="layui-card-body">
                                            <div id="main1" style="width: 100%; height: 400px;">
                                                <script>
                                                    var chartDom = document.getElementById('main1');
                                                    var myChart = echarts.init(chartDom);
                                                    var option;

                                                    option = {
                                                        tooltip: {
                                                            trigger: 'item'
                                                        },
                                                        legend: {
                                                            orient: 'vertical',
                                                            left: 'left',
                                                        },
                                                        series: [
                                                            {
                                                                name: '访问来源',
                                                                type: 'pie',
                                                                radius: '50%',
                                                                data: [
                                                                    {value: 1048, name: '大一'},
                                                                    {value: 735, name: '大二'},
                                                                    {value: 580, name: '大三'},
                                                                    {value: 484, name: '大四'},
                                                                    {value: 300, name: '其他'}
                                                                ],
                                                                emphasis: {
                                                                    itemStyle: {
                                                                        shadowBlur: 10,
                                                                        shadowOffsetX: 0,
                                                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                                                    }
                                                                }
                                                            }
                                                        ]
                                                    };

                                                    option && myChart.setOption(option);

                                                </script>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="padding:20px;">

                    <!--图表三-->
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-md6">
                            <div class="layui-card" style="box-shadow: 0px 0px 10px 3px gainsboro; border-radius: 20px;">
                                <div class="layui-card-header" style="font-weight: bold; font-size: 18px;"><i class="layui-icon layui-icon-slider"></i>专业成员人数统计</div>
                                <div class="layui-card-body">
                                    <div id="main2" style="width: 100%; height: 400px;">
                                        <script>
                                            var chartDom = document.getElementById('main2');
                                            var myChart = echarts.init(chartDom);
                                            var option;

                                            option = {
                                                xAxis: {
                                                    type: 'category',
                                                    data: ['计算机科学与技术', '软件工程', '智能科学与技术', '物联网']
                                                },
                                                yAxis: {
                                                    type: 'value'
                                                },
                                                series: [{
                                                    data: [1500, 2300, 2240, 2180],
                                                    type: 'line'
                                                }]
                                            };

                                            option && myChart.setOption(option);
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-card" style="border-radius: 20px; border: 2px solid buttonface; box-shadow: 0px 0px 10px 3px gainsboro;">
                                <div class="layui-card-header" style="font-weight: bold; font-size: 18px;">产品销售情况比较</div>
                                <div class="layui-card-body">
                                    <div id="main3" style="width: 100%; height: 400px;">
                                        <script>
                                            var chartDom = document.getElementById('main3');
                                            var myChart = echarts.init(chartDom);
                                            var option;

                                            option = {
                                                xAxis: {
                                                    type: 'category',
                                                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                                                },
                                                yAxis: {
                                                    type: 'value'
                                                },
                                                series: [{
                                                    data: [120, 200, 150, 80, 70, 110, 130],
                                                    type: 'bar'
                                                }]
                                            };

                                            option && myChart.setOption(option);
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </div>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加用户 </button>
                <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 批量删除 </button>
            </div>
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        <!-- 自增的模板 -->
        <script type="text/html" id="increment">{{d.LAY_TABLE_INDEX+1}}</script>
        <!-- 用户状态自定义模板 -->
        <script type="text/html" id="status">
            {{d.status == 1?'启用':'禁用'}}
        </script>


    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate
        table = layui.table;
        laydate.render({
            elem: '#date'
            ,type: 'year',
        });


        table.render({
            elem: '#currentTableId',
            url: '../../api/user.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "checkbox", width: 50},
                {field:'increment',width: 50 ,title:'序号',templet:'#increment',align: "center"},
                {field: 'name', width: 100, title: '姓名',align: "center"},
                {field: 'collegeName', width: 130, title: '院系',align: "center"},
                {field: 'major', width: 130, title: '专业', align: "center"},
                {field: 'class', width: 120, title: '班级',align: "center"},
                {field: 'grade', width: 100, title: '年级', sort: true,align: "center"},
                {field: 'phone', width: 120, title: '手机号',align: "center" },
                {field: 'qq', width: 120, title: 'qq',align: "center"},
                {field: 'job', width: 120, title: '校内职务', align: "center"},
                {field: 'status', width: 110, title: '用户状态',align: "center" ,templet: '#status'},
                {title: '操作',fixed:'right', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加用户',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: 'addUser.html',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });


    });
</script>

</body>
</html>